package org.nViron.nvData;

//~--- non-JDK imports --------------------------------------------------------

import java.util.Iterator;

import org.nViron.nvParams.nvContextParamMgr.CONTEXTPARAM;
import org.nViron.nvRender.nvRenderer;
import org.nViron.nvSim.nvObjectMgr;
import org.nViron.nvSim.nvSimulator;

/**
 * manages and updates all data entities
 * @author Roland Haring <p>
 * <script type="text/javascript" src="http://www.ohloh.net/p/376434/widgets/project_basic_stats.js"></script>
 */
public class nvDataEntityMgr extends nvObjectMgr {
    public nvDataEntityMgr(nvSimulator simulator) {
        super(simulator);
    }

    public int addDataEntity(nvDataEntity entity) {
        simulator.addDataEntity(entity);

        return entity.getId();
    }

    public nvDataEntity getDataEntity(int id) {
        return (nvDataEntity) getObject(id);
    }

    public void removeDataEntity(int id) {
        nvDataEntity entity = getDataEntity(id);

        simulator.removeDataEntity(entity);
        remove(id);
    }

    @Override
    public void render(nvRenderer renderer) {
        super.render(renderer);
    }

    @Override
    public void update(float timeStep) {
        super.update(timeStep);
    }

    public void updateAllContextValues() {
        for (Iterator i = getObjects().values().iterator(); i.hasNext(); ) {
            nvDataEntity entity = (nvDataEntity)i.next();
            entity.updateAllContextValues();
        }
    }

    public void updateContextValue(CONTEXTPARAM param) {
        for (Iterator i = getObjects().values().iterator(); i.hasNext(); ) {
            nvDataEntity entity = (nvDataEntity)i.next();
            entity.updateContextValue(param);
        }
    }
}



